import http from "@/util/http";

// curl - X 'POST' \
// 'http://127.0.0.1:8000/api/v1/subject/history/history_action' \
// -H 'accept: application/json' \
// -H 'Content-Type: application/json' \
// -d '{
// "year": 0,
//     "action": "string"
// }'
export async function addHistoryActionAPI(year: number, action: string, tags: string[]) {
    return await http.post('/subject/history/history_action', { year, action, tags });
}

// curl - X 'POST' \
// 'http://127.0.0.1:8000/api/v1/subject/history/find_history_action' \
// -H 'accept: application/json' \
// -H 'Content-Type: application/json' \
// -d '{
// "id": 0,
//     "year": 0,
//         "action": "string",
//             "create_at": "2025-11-07T16:28:57.916Z",
//                 "update_at": "2025-11-07T16:28:57.916Z"
// }'
type HistorySearchModel = {
    id?: number;
    year?: number;
    action?: string;
    create_at?: string;
    update_at?: string;
}
export async function findHistoryActionAPI(search: HistorySearchModel) {
    for (const key in search) {
        if (search[key as keyof HistorySearchModel] === null) {
            delete search[key as keyof HistorySearchModel];
        }
    }
    return await http.post('/subject/history/find_history_action', search);
}